﻿using LibNiconico.NiconicoApi.Lives.Constant;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace LibNiconico.NiconicoApi.Lives.WatchPage
{
    /// <summary>
    /// ニコニコ生放送視聴履歴
    /// </summary>
    public sealed class NicoLiveHistory
    {
        internal const string KEY_NAME = "nicolivehistory";


        private Cookie history;

        private NicoLiveHistory(Cookie cookie)
        {
            this.history = cookie;
        }

        /// <summary>
        /// クッキー取得
        /// </summary>
        /// <returns></returns>
        public Cookie GetCookie()
        {
            return this.history;
        }

        internal static NicoLiveHistory Parse(CookieContainer cookieContainer)
        {
            var cookies = cookieContainer.GetCookies(NicoLiveConstant.WATCH_NICOLIVE_URL);
            return new NicoLiveHistory(cookies[KEY_NAME]);
           
        }

        /// <summary>
        /// System.Object.ToStringをオーバーライドします
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            if (this.history == null) return "";
            return this.history.ToString();
        }
    }
}
